from rest_framework import serializers

from snippets.models import LANGUAGE_CHOICES, STYLE_CHOICES, Snippet

from .models import Student


class StudentSerializer(serializers.ModelSerializer):
    class Meta:
        model = Student  # 指定模型类
        fields = '__all__'  # 序列化所有字段，如果你想序列化特定字段，可以替换为['field1', 'field2', ...]

    # 可选：自定义字段序列化方式
    # def get_name(self, obj):
    #     return obj.name.upper()  # 例如，将名字转换为大写

    # 可选：验证传入数据
    # def validate_age(self, value):
    #     if value < 0 or value > 150:
    #         raise serializers.ValidationError("年龄必须在0到150之间")
    #     return value
